﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using com.zhongjh.Library.Common;

namespace com.zhongjh.Library.Database1
{
    /// <summary>
    /// 数据库访问服务接口
    /// </summary>
    public interface IDbSvc
    {
        /// <summary>
        /// 查询数据库数据(没有参数)
        /// </summary>
        /// <param name="p_strSql"></param>
        /// <param name="p_dtResult"></param>
        /// <returns></returns>
        bool QueryDbDataNoParameter(string p_strSql, ref DataTable p_dtResult);


        /// <summary>
        /// 修改数据库数据(没有参数)
        /// </summary>
        /// <param name="p_strSql"></param>
        /// <returns></returns>
        bool ModifyDbDataNoParameter(string p_strSql);


        /// <summary>
        /// 查询数据库数据(有参数)
        /// </summary>
        /// <param name="p_strSql"></param>
        /// <param name="p_idpDbParameter"></param>
        /// <param name="p_dtResult"></param>
        /// <returns></returns>
        bool QueryDbDataHasParameter(string p_strSql, IDataParameter[] p_idpDbParameter, ref DataTable p_dtResult);


        /// <summary>
        /// 修改数据库数据(有参数)
        /// </summary>
        /// <param name="p_strSql"></param>
        /// <param name="p_idpDbParameter"></param>
        /// <returns></returns>
        bool ModifyDbDataHasParameter(string p_strSql, IDataParameter[] p_idpDbParameter);

        /// <summary>
        /// 查询数据库数据(没有参数)(存储过程)
        /// </summary>
        /// <param name="p_strSql"></param>
        /// <param name="p_dtResult"></param>
        /// <returns></returns>
        bool QueryDBDataNoParameter_SP(string p_strSql, ref DataTable p_dtResult);


        /// <summary>
        /// 修改数据库数据(没有参数)(存储过程)
        /// </summary>
        /// <param name="p_strSql"></param>
        /// <returns></returns>
        bool ModifyDbDataNoParameter_SP(string p_strSql);


        /// <summary>
        /// 查询数据库数据(有参数)(存储过程)
        /// </summary>
        /// <param name="p_strSql"></param>
        /// <param name="p_idpDbParameter"></param>
        /// <param name="p_dtResult"></param>
        /// <returns></returns>
        bool QueryDBDataHasParameter_SP(string p_strSql, IDataParameter[] p_idpDbParameter, ref DataTable p_dtResult);


        /// <summary>
        /// 修改数据库数据(有参数)(存储过程)
        /// </summary>
        /// <param name="p_strSql"></param>
        /// <param name="p_idpDbParameter"></param>
        /// <returns></returns>
        bool ModifyDbDataHasParameter_SP(string p_strSql, IDataParameter[] p_idpDbParameter);


        /// <summary>
        /// 批量保存
        /// </summary>
        /// <param name="p_dsData"></param>
        /// <returns></returns>
        bool BanthSave(DataSet p_dsData);


        /// <summary>
        /// 开始事务
        /// </summary>
        void BeginTransaction();

        /// <summary>
        /// 提交事务
        /// </summary>
        void CommitTransaction();

        /// <summary>
        /// 回滚事务
        /// </summary>
        void RollbackTransaction();

        /// <summary>
        /// 关闭连接
        /// </summary>
        void CloseConnection();

        /// <summary>
        /// 创建数据参数
        /// </summary>
        /// <param name="p_intLength"></param>
        /// <returns></returns>
        IDataParameter[] CreateDataParameter(int p_intLength);

        /// <summary>
        /// 获取序号
        /// </summary>
        /// <param name="p_lngCode"></param>
        /// <returns></returns>
        long GetSN(long p_lngCode);

        /// <summary>
        /// 回收序号
        /// </summary>
        /// <param name="p_lngCode"></param>
        /// <param name="p_lngSn"></param>
        /// <returns></returns>
        bool RecSN(long p_lngCode, long p_lngSn);
    }
}
